package com.mathquiz;

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.print("输入生成数量（如30）：");
        int count = sc.nextInt();
        System.out.print("选择模式（add/sub/mul/div/mix2/mixmd/mix3）：");
        String mode = sc.next();
        System.out.print("每行列数（如5）：");
        int cols = sc.nextInt();

        List<Question> quiz = Generator.generate(count, mode);
        Utils.saveCSV(quiz, "output/quiz.csv", cols);
     // ===== 新增：控制台也显示一遍 =====
        System.out.println("\n===== 题目如下 =====");
        for (int i = 0; i < quiz.size(); i++) {
            System.out.print(quiz.get(i));
            if ((i + 1) % cols == 0) System.out.println();
            else System.out.print("\t");
        }
        if (quiz.size() % cols != 0) System.out.println();
        // ==================================
        System.out.println("✅ 已生成 " + count + " 道题，保存至 output/quiz.csv");
    }
}